export function _toast(title, cb = () => {}, duration = 1500){
  wx.showToast({
    icon: 'none',
    title,
    duration,
    success(){
      let timer = setTimeout(() => {
        clearTimeout(timer)
        cb()
      },500)
    }
  })
}

export function getValue(e){
  let { type } = e.currentTarget.dataset
  this.setData({[type]: e.detail.value})
}

export function _closeLayer(e){
  let { type } = e.currentTarget.dataset
  $close.call(this, type)
}

export function $close(type){
  this.setData({[type]: false})
}

export function _openLayer(e){
  let { type } = e.currentTarget.dataset
  $open.call(this, type)
}

export function $open(type){
  this.setData({[type]: true})
}

// 复制文本
export function getClipboardData(e){
  let {content} = e.currentTarget.dataset;
  wx.setClipboardData({ data: content })
}

// 打电话
export function makePhoneCall(e){
  let {phone} = e.currentTarget.dataset;
  wx.makePhoneCall({phoneNumber: phone || '02896000'}).catch(console.log)
}